<template>
	<view>
		
		<view class="logBox">
			<view class="logItem" v-for="(item,index) in logList" :key="index">
				<view class="logItemLeft">
					{{item.text}}
					<text>{{item.add_time_str}}</text>
				</view>
				<view class="logItemRight">
					+{{item.num}}
				</view>
			</view>
		</view>
		
		<!-- 空数据 -->
		<view class="dataEmpty_con" v-if="logList.length==0">
			<u-empty></u-empty>
		</view>
		
		
		
		
	</view>
</template>

<script>
	
	export default {
		
		data() {
			return {
				// 分页
				pages: 1,
				limit: 10,
				last_page: 0,
				
				// 加载更多
				loadStatus: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '上拉或点击加载更多',
					loading: '努力加载中',
					nomore: '没有更多了'
				},
				
				logList:[],
				
			}
		},
		onLoad(e){
			
		},
		onShow(){
			var _this=this;
			_this.pages=1;
			_this.getLogList()
			
		},
		
		onReachBottom() {
			var _this = this;
			_this.loadmore();
		},
		methods: {
			
			
			
			// 获取消息通知列表
			getLogList() {
				var _this = this;
				_this.$u.get('/api/user.integral/getList', {
					pages: _this.pages,
					limit: _this.limit,
					
				}).then(res => {
					uni.hideLoading();
					var logList = _this.logList;
					if (_this.pages == 1) {
						logList = [];
					}
					_this.logList = logList.concat(res.data);
					
			
					// 分页状态更新
					_this.last_page = res.extend.last_page;
					if (_this.pages >= _this.last_page) _this.loadStatus = 'nomore';
					else _this.loadStatus = 'loadmore';
				}).catch(res => {
					console.log(res);
				})
			},
			
			// 点击加载更多
			loadmore() {
				var _this = this;
				if (_this.pages >= _this.last_page) return;
				_this.loadStatus = 'loading';
				_this.pages++;
			
				setTimeout(() => {
					if (_this.pages >= _this.last_page) _this.loadStatus = 'nomore';
					else _this.loadStatus = 'loading';
					uni.showLoading({
						title: '加载中'
					});
					_this.getLogList();
				}, 2000)
			},
			
			
		}
	}
</script>
<style>
	page{
		background-color: #fff;
	}
</style>
<style scoped lang="scss">
	.logBox{
		width: 690rpx;
		margin:0 auto;
		background-color:#fff;
		border-radius: $uni-radius;
	}
	.logItem{
		padding: 20rpx;
		border-bottom: 2rpx solid #eee;
		overflow: hidden;
	}
	.logItemLeft{
		float: left;
		width: 400rpx;
		height: 100rpx;
		line-height: 50rpx;
		font-size: 32rpx;
		color: $uni-color;
	}
	.logItemLeft text{
		display: block;
		color: $uni-color-text;
		font-size: 24rpx;
	}
	.logItemRight{
		float: right;
		text-align: right;
		line-height: 100rpx;
		font-weight: bold;
		font-size: 40rpx;
	}
	
	
</style>
